// Device/pages/HistoryInfo/index.js
import { getParams } from '@/utils/util';
import { fetchDeviceInfo } from '@/services/device';
const componentMappings = new Map([
    [
        8, {
            'A666G': 'bpgauge-component',
            'X2A': 'bpgauge-component',
            'YE620AR': 'bpgauge-component'
        }
    ],
    [
        9, {
            'G777G': 'glucometer-component',
            'T808': 'glucometer-component',
            '302G': 'glucometer-component'
        }
    ]
])
Page({
  data: {
    currentComponent: null,
    record_info: null
  },
  async onLoad(options) {
    const { device_imei } = getParams(options.params);
    const { data: { blood_sugar_info, blood_pressure_info, device_type, product_type } } = await fetchDeviceInfo({ device_imei });
    this.setData({
        blood_sugar_info,
        blood_pressure_info,
        record_info: getParams(options.params),
        currentComponent: componentMappings.get(device_type)[product_type]
    })
  }
})